<?php
namespace app\service;

use app\model\SysAccount;
use app\utils\ResposeUtils;
use think\facade\Db;

class SysAccountService
{
    public function list(SysAccount $sysAccount){
        $query   = SysAccount::createQuery($sysAccount);
        $count=$query->count();
        $datalist = $query->select();
        return ResposeUtils::ok([
            "data"=>$datalist,
        ],200,$count);
    }
    public function getbyid(int $id){
        $query   = SysAccount::createQueryById($id);
        $datalist = $query->find();
        return ResposeUtils::ok([
            "data"=>$datalist,
        ],200);
    }
    public function add(SysAccount $sysAccountData){
        $result = SysAccount::create($sysAccountData);
        return ResposeUtils::ok([
            "data"=>$result,
        ],200);
    }
    public function update(SysAccount $sysAccountData,int $id){

        $result=SysAccount::update($sysAccountData, ['id' => $id]);
        return ResposeUtils::ok([
            "data"=>$result,
        ],200);
    }
}
